package com.caiyi.financial.nirvana.sms.handler;

import com.caiyi.financial.nirvana.sms.gateway.Controller;
import com.caiyi.financial.nirvana.sms.gateway.GatewayActionThread;
import com.caiyi.financial.nirvana.sms.gateway.GatewayNotifyThread;
import com.caiyi.financial.nirvana.sms.gateway.GatewayReceiveMsgThread;
import com.caiyi.financial.nirvana.sms.server.CmppServer;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * Created by Mario on 2017/12/20 0020.
 * 项目启动
 */
@Component
public class StartHandler extends ApplicationHandler {

    private final static int CMPP_PORT = 8086;

    @Override
    public void start(ApplicationContext applicationContext) {
        //网关初始化
        Controller.initGateWay();
        //网关行为线程
        Runnable gatewayAction = new GatewayActionThread();
        new Thread(gatewayAction).start();
        //网关回调处理线程
        Runnable notifyThread = new GatewayNotifyThread();
        new Thread(notifyThread).start();
        //上行短信处理线程
        Runnable receiveThread = new GatewayReceiveMsgThread();
        new Thread(receiveThread).start();
        //CMPP接口服务
        Runnable cmppServer = new CmppServer(CMPP_PORT);
        new Thread(cmppServer).start();
    }


}
